﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using DBUtility;//请先添加引用
namespace TierApplication
{
    /// <summary>
    /// 类P_Version。
    /// </summary>

    public partial class P_Version
    {
        public static DataSet GetUpdateVersionList()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * ");
            strSql.Append(" FROM [P_Version_Update] ");
            return DbHelperSQL.Query(strSql.ToString());
        }

        public void GetModelByName(string sMC)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select MC,BBH,WJDX,XGRQ,LJ,SCR,SCRQ,BZ ");
            strSql.Append(" FROM [P_Version_Update] ");
            strSql.Append(" where MC=@MC ");
            SqlParameter[] parameters = {
					new SqlParameter("@MC", SqlDbType.VarChar)};
            parameters[0].Value = sMC;

            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["MC"] != null && ds.Tables[0].Rows[0]["MC"].ToString() != "")
                {
                    this.MC = ds.Tables[0].Rows[0]["MC"].ToString();
                }
                if (ds.Tables[0].Rows[0]["BBH"] != null && ds.Tables[0].Rows[0]["BBH"].ToString() != "")
                {
                    this.BBH = int.Parse(ds.Tables[0].Rows[0]["BBH"].ToString());
                }
                if (ds.Tables[0].Rows[0]["WJDX"] != null && ds.Tables[0].Rows[0]["WJDX"].ToString() != "")
                {
                    this.WJDX = decimal.Parse(ds.Tables[0].Rows[0]["WJDX"].ToString());
                }
                if (ds.Tables[0].Rows[0]["XGRQ"] != null && ds.Tables[0].Rows[0]["XGRQ"].ToString() != "")
                {
                    this.XGRQ = DateTime.Parse(ds.Tables[0].Rows[0]["XGRQ"].ToString());
                }
                if (ds.Tables[0].Rows[0]["LJ"] != null && ds.Tables[0].Rows[0]["LJ"].ToString() != "")
                {
                    this.LJ = ds.Tables[0].Rows[0]["LJ"].ToString();
                }
                if (ds.Tables[0].Rows[0]["SCR"] != null && ds.Tables[0].Rows[0]["SCR"].ToString() != "")
                {
                    this.SCR = ds.Tables[0].Rows[0]["SCR"].ToString();
                }
                if (ds.Tables[0].Rows[0]["SCRQ"] != null && ds.Tables[0].Rows[0]["SCRQ"].ToString() != "")
                {
                    this.SCRQ = DateTime.Parse(ds.Tables[0].Rows[0]["SCRQ"].ToString());
                }
                if (ds.Tables[0].Rows[0]["BZ"] != null && ds.Tables[0].Rows[0]["BZ"].ToString() != "")
                {
                    this.BZ = ds.Tables[0].Rows[0]["BZ"].ToString();
                }
            }


        }

        public bool DeleteByName(string MC)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from [P_Version] ");
            strSql.Append(" where MC=@MC ");
            SqlParameter[] parameters = {
					new SqlParameter("@MC", SqlDbType.VarChar)};
            parameters[0].Value = MC;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }

}
